package com.unknowpupil.web.tool;

import com.unknowpupil.web.domain.Account;
import com.unknowpupil.web.service.IAccountService;
import com.unknowpupil.web.utils.SerialCodeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Classname: CreateInvitationWord
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2019/11/7 11:04
 * @Description:
 * @Version: 1.0
 */

@Component
public class CreateInvitationWordTool {
    @Autowired
    private  IAccountService accountService;

    /**
     * 递归生成用户推荐码
     * @param str
     * @return
     */
    public  String createInvitationCode(String str){
         str = SerialCodeUtil.generateString(6);
        if(accountService.unique("invitationCode",str)){
            return str;
        }else{
            return createInvitationCode(str);
        }
    }


}
